﻿Chenxin.UI.PublishDetailInfo=Chenxin.extend(Chenxin.UI.PageCommon,{
    autoInitForm:false,
    actionUrl:'/service/PublishDetailInfo.ashx',
    loadinfo: function(callback,scope) {
        var _this = this;
        Chenxin.ajax({
            type: "get",
            dataType: "text",
            paramType: 'json',
            async:false,
            url: this.actionUrl,
            data: { op: 'getmodel', modelid: this.currentId },
            onSuccess: function(data, msg) {
                if (data) {
                    _this.currentPublish = data;
                    if(callback){
                        callback.call(scope);
                    }
                }
            }
        });
    },
	initEvent: function() {
        var _this = this;
        
//        //编辑
//        $('#btn_edit').live('click', function() {		
//			Chenxin.Fn.checkPermit(_this.actionUrl,'editpublic',function(data,msg){
//				if(data.permit!=undefined){
//					_this.permit=data.permit;	
//				}
//			},this);
//			if(_this.permit){			
//                window.location.href = "/PublishInfo/InfoPublish.aspx?RecordId="+this.name+"";
//			}else{
//				alert('您没有此权限，请联系管理员！');
//			}

//		});
//		
//		//删除
//        $('#btn_del').live('click', function() {		
//            Chenxin.ajax({
//                type: "post",
//                dataType: "json",
//                async:false,
//                url: _this.actionUrl,
//                data: { op: 'delpublic',recordid:this.name},
//                onSuccess: function(data, msg) {
//                    alert(msg);
//                    window.location.href = "/PublishInfo/PublicInfo.aspx?Type="+data.InfoType+"";
//                }
//            });
//		});
		
		
		//编辑
        $('#btn_edit').live('click', function() {
            _this.currentId = this.name;
            _this.loadinfo();
            var _data = {};
            Chenxin.apply(_data,_this.currentPublish); 
            if(_data.PublisherId==_data.DepartId)
            {
//                Chenxin.Fn.checkPermit(_this.actionUrl,'editpublic',function(data,msg){
//				    if(data.permit!=undefined){
//					    _this.permit=data.permit;
//				    }
//			    },this);
//			    if(_this.permit)
//			    {
//                    window.location.href = "/PublishInfo/InfoPublish.aspx?RecordId="+this.name+"";
//                }
//                else
//                {
//                    alert('您没有此权限，请联系管理员！');
//                }
                window.location.href = "/PublishInfo/InfoPublish.aspx?RecordId="+this.name+"";
            }
            else
            {
		        Chenxin.Fn.checkPermit(_this.actionUrl,'mgrpublic',function(data,msg){
			        if(data.permit!=undefined){
				        _this.permit=data.permit;
			        }
		        },this);
		        if(!_this.permit)
		        {   
			        alert('您没有此权限，请联系管理员！');
			    }
			    else
			    {
			        window.location.href = "/PublishInfo/InfoPublish.aspx?RecordId="+this.name+"";
			    }
			}
		});
		
		//删除
        $('#btn_del').live('click', function() {
            _this.currentId = this.name;
            _this.loadinfo();
            var _data = {};
            Chenxin.apply(_data,_this.currentPublish); 
            if(_data.PublisherId==_data.DepartId)
            {
                Chenxin.ajax({
                    type: "post",
                    dataType: "json",
                    async:false,
                    url: _this.actionUrl,
                    data: { op: 'delpublic',recordid:this.name},
                    onSuccess: function(data, msg) {
                        alert(msg);
                        window.location.href = "/PublishInfo/PublicInfo.aspx?Type="+data.InfoType+"";
                    }
                });
            }
            else
            {
                Chenxin.Fn.checkPermit(_this.actionUrl,'mgrpublic',function(data,msg){
				    if(data.permit!=undefined){
					    _this.permit=data.permit;
				    }
			    },this);
			    if(!_this.permit)
		        {
		            alert('您没有此权限，请联系管理员！');
			    }
			    else
			    {
                    Chenxin.ajax({
                        type: "post",
                        dataType: "json",
                        async:false,
                        url: _this.actionUrl,
                        data: { op: 'mgrpublic',recordid:this.name},
                        onSuccess: function(data, msg) {
                            alert(msg);
                            window.location.href = "/PublishInfo/PublicInfo.aspx?Type="+data.InfoType+"";
                        }
                    });
                }
            }
		});
    },
	initComponent:function(){
	    Chenxin.UI.PublishDetailInfo.superclass.initComponent.call(this);
	}
}); 

$(document).ready(function() {
    $('#aaa').hide();
    this.PublishDetailInfo=new Chenxin.UI.PublishDetailInfo();
});